<template>
  <div class="app-container" v-loading="appLoading">
    <!-- 高级查询 -->
    <div class="filter_container">
      <el-tabs v-model="queryParams.status" type="card" @tab-click="handleQuery">
        <el-tab-pane name="newRece">
          <span slot="label"><i class="el-icon-s-order" /> 新收到</span>
        </el-tab-pane>
        <el-tab-pane name="acc_gen">
          <span slot="label"><i class="el-icon-bank-card" /> 结算成功</span>
        </el-tab-pane>
        <el-tab-pane name="acc_failed">
          <span slot="label"><i class="el-icon-bank-card" /> 结算失败</span>
        </el-tab-pane>
      </el-tabs>
     </div>
    <el-form v-show="searchVisible" ref="queryForm" :model="queryParams" :inline="true">
    <el-form-item label="商城:">
      <el-select v-model="queryParams.customerNo" placeholder="请选择商城编号" clearable size="mini">
        <el-option v-for="option in options.customers" :key="option.id" :label="option.customerName" :value="option.id" />
      </el-select>
    </el-form-item>
    <el-form-item label="商城订单号:">
       <el-input v-model="queryParams.custSalesOrderNo" size="mini" placeholder="请输入订单号" clearable @keyup.enter.native="handleQuery" />
     </el-form-item>
    <!-- <el-form-item label="客户订单号:">
       <el-input v-model="queryParams.custSalesOrderNo" size="small" placeholder="请输入订单号" clearable @keyup.enter.native="handleQuery" />
     </el-form-item> -->
     <el-form-item label="子订单号:">
       <el-input v-model="queryParams.custSalesOrderItemNo" size="mini" placeholder="请输入订单号" clearable @keyup.enter.native="handleQuery" />
     </el-form-item>
     <el-form-item label="商城SPU:">
       <el-input v-model="queryParams.custSpuId" size="mini" placeholder="请输入商城SPU" width="1" clearable @keyup.enter.native="handleQuery" />
     </el-form-item>
     <el-form-item label="商城SKU:">
       <el-input v-model="queryParams.custSkuId" size="mini" placeholder="请输入商城SKU" width="1" clearable @keyup.enter.native="handleQuery" />
     </el-form-item>
     <el-form-item label="店铺:">
       <el-select v-model="queryParams.storeId" placeholder="请选择店铺编号" filterable clearable size="mini">
         <el-option v-for="option in options.storeOptions" :key="option.storeCode" :label="option.storeName" :value="option.storeCode" />
       </el-select>
     </el-form-item>
     <el-form-item label="自" prop="orderTimeFr">
       <el-date-picker v-model="queryParams.orderTimeFr" type="date" value-format="yyyy-MM-dd" size="mini" style="width: 200px" placeholder="选择时间始" clearable />
     </el-form-item>
     <el-form-item label="至" prop="orderTimeTo">
       <el-date-picker v-model="queryParams.orderTimeTo" type="date" value-format="yyyy-MM-dd" size="mini" style="width: 200px" placeholder="选择时间至" clearable />
     </el-form-item>

    <!-- <el-form-item label="供应商编号:">
      <el-select v-model="queryParams.supplierNo" placeholder="请选择供应商编号" clearable size="small">
        <el-option v-for="option in options.supplierIdOptions" :key="option.id" :label="option.supplierName" :value="option.id" />
      </el-select>
    </el-form-item> -->
   <!-- <el-form-item label="店铺:">
       <el-input v-model="queryParams.storeName" size="small" placeholder="请输入收货人手机" clearable @keyup.enter.native="handleQuery" />
     </el-form-item> -->
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      <el-button  v-if="queryParams.status === `newRece`" v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="generateSettlement">自动生成结算单</el-button>
      <el-button v-if="queryParams.status === `newRece`" v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="batchGenerateSettlement">选择生成结算单</el-button>
      <el-button  v-if="queryParams.status === `acc_failed`" type="info" icon="el-icon-upload2" size="mini" @click="reGenerateSettlement">自动再次结算</el-button>
      <el-button v-if="queryParams.status === `acc_failed`" v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="batchReGenerateSettlement">选择再次结算</el-button>
      
      <el-button  v-if="queryParams.status === `acc_failed`" v-loading="exportLoading"  type="info" icon="el-icon-download" size="mini" @click="handleExport">导出失败结算</el-button>

      </el-form-item>
    </el-form>

    <!-- 工具栏 -->
    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button v-hasPermission="['order:salesOrder:insert']" type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col> -->
    <!--  <el-col :span="1.5">
        <el-button v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="openUploadDialog">批量订单导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="retrieveOrders">获得新订单</el-button>
      </el-col> -->
     <!-- <el-col :span="1.5">
        <el-button v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="generateSettlement">自动生成结算单</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['order:salesOrder:insert']" type="info" icon="el-icon-upload2" size="mini" @click="batchGenerateSettlement">选择生成结算单</el-button>
      </el-col> -->
      <pagination v-show="page.total>0" :total="page.total" :page.sync="page.current" :limit.sync="page.pageSize" @pagination="handleQuery" />

  <!--    <right-toolbar :show-search.sync="searchVisible" @queryTable="handleQuery" />
  -->  </el-row>

    <!-- 数据列表 -->
    <el-table v-loading="loading" :data="page.records" highlight-current-row @selection-change="handleSelectionChange" @sort-change="handleSortChange">
      <el-table-column type="selection" width="55" align="center" />
   <!--  <el-table-column label="结算ID" align="center" width="150" prop="salesOrderNo" />
   -->   <el-table-column label="状态" align="center" width="90">
       <template slot-scope="scope">
          <span>{{ scope.row.status | settleStatusFilter }}</span>
        </template>
      </el-table-column>
     <!-- <el-table-column v-if="queryParams.status === `acc_failed`" label="导入验证信息" width="155" align="center" prop="importErrorMesg" />
     --> <el-table-column  v-if="queryParams.status === `acc_failed`" label="结算处理信息" width="475" show-overflow-tooltip align="center" prop="genAccFailedReason" />

     <!-- <el-table-column label="导入验证信息" width="155" align="center" prop="importErrorMesg" />
     --> <el-table-column label="商城" align="center" sortable width="150" prop="customerName" />
      <el-table-column label="客户子单号" align="center" sortable width="170" prop="custSalesOrderItemNo" />
      <el-table-column label="商品名" align="center" show-overflow-tooltip prop="skuName" sortable width="130"/>
      <el-table-column label="商城SPU" align="center" show-overflow-tooltip sortable width="130">
      <template slot-scope="scope">
        <el-button type="text" @click="handlePriceView(scope.row)">{{ scope.row.custSpuId }}</el-button>
      </template>
       </el-table-column>
       <el-table-column label="商城Sku" align="center" prop="custSkuId" sortable  width="150"/>

      <el-table-column label="活动编号" align="center" show-overflow-tooltip width="90">
      <template slot-scope="scope">
        <el-button type="text" @click="handleActivityPriceView(scope.row)">{{ scope.row.discountActivityCode }}</el-button>
      </template>
      </el-table-column>

      <el-table-column label="店铺名称" align="center" prop="storeName"  width="150"/>
      <el-table-column label="商品数量" align="right" prop="qty" />
      <el-table-column label="营销委结算价" align="right"  prop="custRelSalesPrice" />
      <el-table-column label="营销委结算单价" align="right"  prop="custRelSalesUnitPrice" />
      <el-table-column label="订单金额" align="right"  prop="custCashPaymentAmt" />
      <el-table-column label="订单里程" align="right" prop="custMilePaymentAmt" />
     <el-table-column label="领券码" align="center" show-overflow-tooltip prop="storeDiscountCode" />
      <el-table-column label="领券金额" align="right" prop="storeDiscountAmt" />
       <el-table-column label="领券里程" align="right" prop="storeDiscountAmtPoint" />
      <el-table-column label="活动名称" width="130"  align="center" prop="discountActivityName" />
     <el-table-column label="供应商名称" width="150" show-overflow-tooltip align="center"  prop="supplierName" />
      <el-table-column label="订单号" width="150" align="center" sortable prop="custSalesOrderNo" />
      <el-table-column label="销售单价" align="right" prop="custSaleUnitPrice" />
      <el-table-column label="收货人" align="center" prop="consigneeName" />
      <el-table-column label="商品属性" show-overflow-tooltip align="center" prop="productAttribution" />
      <el-table-column label="退单金额" align="right" prop="returnAmt" />
       <el-table-column label="退单代码" align="center" prop="returnQty" />
     <!-- <el-table-column label="订单来源" align="center" width="180"> -->
    <!--  <el-table-column label="报错代码" align="center" prop="errorCode" /> -->
   <!--   <el-table-column label="客户留言" align="center" prop="custNote" /> -->
      <el-table-column label="订单日期" align="center" prop="createTime" width="160">
         <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
        <!-- <template slot-scope="scope">
          <span>{{ orderSourceFormat(scope.row.sourceType) }}</span>
        </template>
      </el-table-column> -->
    <!--  <el-table-column label="操作" align="center" fixed="right" width="150">
  -->  <!--  <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
    -->   <!-- <template slot-scope="scope"> -->
       <!--   <el-button v-hasPermission="['order:salesOrder:update']" size="mini" type="text" @click="handleEdit(scope.row)">查看</el-button>
      -->    <!-- <el-dropdown type="text" split-button> -->
        <!--    <el-button type="text" icon="el-icon-edit" @click="handleGenerateArAmt(scope.row)">生成结算</el-button>
        -->
           <!-- <el-dropdown-menu slot="dropdown">
              <el-dropdown-item v-hasPermission="['order:salesOrder:update']" size="mini" type="primary" plain :disabled="scope.row.orderStatus !== 'created'" @click.native="handleEdit(scope.row)">修改</el-dropdown-item>
              <el-dropdown-item v-if="handleApAmtBtnShow(scope.row.status)" icon="el-icon-receiving" divided @click.native="handleSettle(scope.row)">再次结算</el-dropdown-item>
        -->     <!-- <el-dropdown-item v-if="handleApAmtBtnShow(scope.row.orderStatus)" icon="el-icon-receiving" divided @click.native="openApAmtDialog(scope.row)">生成结算</el-dropdown-item>
            -->  <!-- <el-dropdown-item v-if="handleReimportBtnShow(scope.row.errorFlag)" icon="el-icon-receiving" divided @click.native="handleImport(scope.row)">修复数据</el-dropdown-item>
      -->      <!--  <el-dropdown-item v-hasPermission="['order:salesOrder:update']" size="mini" type="primary" plain :disabled="scope.row.orderStatus !== 'created'" @click.native="handleEdit(scope.row)">下载提案/报价</el-dropdown-item>
            --><!--   <el-dropdown-item v-if="handleReturnBtnShow(scope.row.status)" icon="el-icon-receiving" divided @click.native="handleReturn(scope.row)">退单处理</el-dropdown-item>

            <el-dropdown-item v-hasPermission="['order:salesOrder:delete']" size="mini" type="primary" plain :disabled="scope.row.orderStatus !== 'created'" @click.native="handleRemove(scope.row)">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column> -->
    </el-table>

    <!-- 分页 -->
  <!-- 导入对话框 -->
    <el-dialog :title="uploadDialog.title" :visible.sync="uploadDialog.visible" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        :headers="uploadData.headers"
        :action="uploadData.url + '?updateSupport=' + uploadData.updateSupport"
        :data="uploadData.params"
        :disabled="uploadData.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        accept=".xlsx, .xls"
        drag
      >
        <i class="el-icon-upload" />
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div slot="tip" class="el-upload__tip">
          <el-select v-model="uploadData.params.customerNo" style="width: 100%" filterable clearable placeholder="请选择下单客户" @change="handleSelected">
            <el-option v-for="option in options.customers" :key="option.id" :label="option.customerName" :value="option.id" />
          </el-select>

          <el-link type="info" style="font-size:12px" @click="handleDownloadTemplate">下载模板</el-link>
        </div>
        <div slot="tip" class="el-upload__tip" style="color:red">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmUploadDialog">确 定</el-button>
        <el-button @click="resetUploadDialog">取 消</el-button>
      </div>
    </el-dialog>
    <div class="dialog_container">
      <!--退单-->
      <el-dialog
        :title="returnDialog.title"
        :close-on-click-modal="false"
        :before-close="closeReturnDialog"
        :visible.sync="returnDialog.visible"
        width="35%"
      >
        <el-form :model="returnDialogData" label-position="right" label-width="120px" class="dialog_form">
          <el-form-item label="退单数量：">
            <el-input v-model="returnDialogData.returnQty" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="closeReturnDialog()">取消</el-button>
          <el-button type="primary" @click="confirmReturnDialog()">保存</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import SalesOrderApi from '@/api/order/SalesOrderApi'
import AccountingApApi from '@/api/accounting/AccountingApApi'
import SalesOrderItemApi from '@/api/order/SalesOrderItemApi'
import CustomerApi from '@/api/basic/CustomerApi'
import StoreApi from '@/api/basic/StoreApi'
import SupplierApi from '@/api/basic/SupplierApi'
import DictValueApi from '@/api/system/DictValueApi'
import appConstant from '@/constant/AppConstant'
import AuthUtils from '@/utils/AuthUtils'
export default {
  name: 'OmsSalesOrderList',
  filters: {
    settleStatusFilter(item) {
      const values = appConstant.settleStatusList.filter(value => value.key === item)
      if (values && values.length > 0) {
        return values[0].label
      } else {
        return ''
      }
    }
   },
  data() {
    return {
      options: {
        sysYnTypeOptions: [],
        orderTypeOptions: [],
        sourceTypeOptions: [],
        supplierIdOptions: [],
        settleStatusOptions: appConstant.settleStatusList,
        salesOrderStatusOptions: [],
        storeOptions: [],
        customers: [],
        payTypeOptions: []
      },
      queryParams: {
        customerNo: null,
        custSalesOrderNo: null,
        custSalesOrderItemNo: null,
        orderTimeTo: null,
        orderTimeFr: null,
        status: null,
        errorFlag: null,
        receiverName: null,
        receiverMobile: null,
        custSpuId: null,
        custSkuId: null,
        storeId: null,
        isValid: this.$constant.Y,
        sortProperty: null,
        sortDirection: null
      },
      page: {
        current: 1,
        pageSize: 10,
        total: 0,
        records: []
      },
      uploadDialog: {
        title: '订单批量导入',
        visible: false
      },
      uploadData: {
        headers: { Authorization: 'Bearer ' + AuthUtils.getToken() }, // 上传请求头
        url: process.env.VUE_APP_BASE_API + '/order/salesOrderItem/importData', // 上传的地址
        params: {
          customerNo: null
        },
        isUploading: false, // 是否禁用上传
        updateSupport: 0 // 是否更新已经存在的数据
      },
      returnDialog: {
        title: '退单',
        visible: false
      },
      returnDialogData: {
       returnQty: null,
       id: null
      },
      loading: true,
      exportLoading: false,
      appLoading: false,
      searchVisible: true,
      multipleSelection: [],
      isSingle: true,
      isMultiple: true
    }
  },
  created() {
    this.initParam()
    this.handleQuery()
    this.loadOptions()
  },
  methods: {
    initParam() {
      this.queryParams.orderTimeFr = this.getBeforeDay(3)
      this.queryParams.orderTimeTo = this.parseTime(new Date(), '{y}-{m}-{d}')
      console.log(this.queryParams)
    },
    loadOptions() {
      CustomerApi.list().then(response => {
        this.options.customers = response.data
      })
      StoreApi.list().then(response => {
        this.options.storeOptions = response.data
      })
    /*  SupplierApi.list().then(response => {
         this.options.supplierIdOptions = response.data
       }) */
      /* StoreApi.list().then(response => {
         that.options.storeOptions = response.data
       }) */
     /* DictValueApi.list({ dictCode: 'oms_sales_order_type' }).then(response => {
        this.options.orderTypeOptions = response.data
      })
      DictValueApi.list({ dictCode: 'oms_sales_order_source' }).then(response => {
        this.options.sourceTypeOptions = response.data
      })
      DictValueApi.list({ dictCode: 'oms_sales_order_status' }).then(response => {
        this.options.salesOrderStatusOptions = response.data
      })
      DictValueApi.list({ dictCode: 'sys_payment_type' }).then(response => {
        this.options.payTypeOptions = response.data
      }) */
    },
    handleAdd() {
      this.$router.push('/salesOrder/form/')
    },
    handlePriceView(row) {
      this.$router.push({ path: `/materialBuyPrice/materialBuyPriceSpuList/${row.custSpuId}` })
    },
    handleActivityPriceView(row) {
      this.$router.push({ path: `/promotionDiscountPrice/promotionDiscountPriceSpuList/${row.custSpuId}` })
    },
    handleReimportBtnShow: function(status) {
      const validStatusList = ['Y']
      const index = validStatusList.indexOf(status)
      if (index === -1) {
        return false
      } else {
        return true
      }
    },
    handleApAmtBtnShow: function(status) {
      const validStatusList = ['acc_failed']
      const index = validStatusList.indexOf(status)
      if (index === -1) {
        return false
      } else {
        return true
      }
    },
    handleReturnBtnShow: function(status) {
      const validStatusList = ['newRece', 'acc_gen', 'acc_failed']
      const index = validStatusList.indexOf(status)
      if (index === -1) {
        return false
      } else {
        return true
      }
    },
    handleSettle(row) {
      debugger
      const ids = row.id
      AccountingApApi.settleAgain(ids).then(() => {
        this.$message.success('生成结算成功!')
        this.handleQuery()
      })
    },

   handleReturn(row) {
        this.returnDialog.visible = true
        this.returnDialogData.returnQty = row.qty
        this.returnDialogData.id = row.id
   },
    closeReturnDialog() {
      this.returnDialog = {
        title: '退单',
        visible: false
      }
      this.returnDialogData = {
        returnQty: null
      }
       this.handleQuery()
    },
    confirmReturnDialog() {
        const params = {
          returnQty: this.returnDialogData.returnQty,
          id: this.returnDialogData.id
       }
        SalesOrderItemApi.createReturn(params).then(() => {
          this.$message.success('退单成功!')
          this.closeReturnDialog()
        })
        this.handleQuery()
    },
    handleRemove(row) {
      this.$confirm('是否确认删除数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return SalesOrderApi.remove(row.id)
      }).then(() => {
        this.handleQuery()
        this.$message.success('删除成功')
      })
    },
    reGenerateSettlement() {
      this.appLoading = true
      AccountingApApi.regenerateArAp().then(() => {
        this.appLoading = false
        this.$message.success('再次生成结算成功!')
        this.handleQuery()
      }).catch(error => {
        console.log(error)
        this.$message.error('再次生成结算失败!')
        this.appLoading = false
      })
    },
    generateSettlement() {
      this.appLoading = true
      AccountingApApi.generateArAp().then(() => {
        this.appLoading = false
        this.$message.success('生成结算成功!')
        this.handleQuery()
      }).catch(error => {
        console.log(error)
        this.$message.error('生成结算失败!')
        this.appLoading = false
      })
    },
    
    batchReGenerateSettlement() {
      if (!this.multipleSelection || this.multipleSelection.length === 0){
        return false
      }
      for (let i = 0; i < this.multipleSelection.length; i++) {
        const row = this.multipleSelection[i]
        // 有结算成功或结算失败的订单时，不允许提交
        if (row.status === 'acc_gen' ){
          this.$message.error('结算成功的订单不能提交!')
          return false
        }
      }
      const ids = this.multipleSelection.map(item => item.id)
      this.appLoading = true
      AccountingApApi.batchGenerateArAp(ids).then(() => {
        this.appLoading = false
        this.$message.success('生成结算成功!')
        this.handleQuery()
      }).catch(error => {
        console.log(error)
        this.$message.error('生成结算失败!')
        this.appLoading = false
      })
    },
    batchGenerateSettlement() {
      if (!this.multipleSelection || this.multipleSelection.length === 0){
        return false
      }
      for (let i = 0; i < this.multipleSelection.length; i++) {
        const row = this.multipleSelection[i]
        // 有结算成功或结算失败的订单时，不允许提交
        if (row.status === 'acc_gen' ){
          this.$message.error('结算成功的订单不能提交!')
          return false
        }
      }
      const ids = this.multipleSelection.map(item => item.id)
      this.appLoading = true
      AccountingApApi.batchGenerateArAp(ids).then(() => {
        this.appLoading = false
        this.$message.success('生成结算成功!')
        this.handleQuery()
      }).catch(error => {
        console.log(error)
        this.$message.error('生成结算失败!')
        this.appLoading = false
      })
    },
    handleEdit(row) {
      this.$router.push({ path: '/salesOrder/form/' + row.id })
    },
    handleQuery() {
      this.loading = true
     // this.queryParams.errorFlag = 'N'
      SalesOrderItemApi.page(this.queryParams, this.page).then(response => {
        this.page.records = response.data.records
        this.page.total = response.data.total
        this.loading = false
      }, () => {
        this.loading = false
      })
    },
    handleExport() {
      // if (!this.queryParams.storeId) {
      //   this.$message.warning('导出操作店铺不能为空')
      //   return false
      // }
      let that = this
      this.$confirm('是否确认导出失败结算订单数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        that.exportLoading = true
        return SalesOrderItemApi.exportData(that.queryParams)
      }).then(response => {
        that.exportLoading = false
        this.$common.download(response.data)
      }).catch(() => {
        that.exportLoading = false
      })
    },
    handleSortChange(sort) {
      if (sort.order) {
        this.queryParams.sortProperty = sort.prop
        this.queryParams.sortDirection = sort.order === 'ascending' ? 'asc' : 'desc'
      } else {
        this.queryParams.sortProperty = null
        this.queryParams.sortDirection = null
      }
      this.handleQuery()
    },
    handleSelectionChange(selection) {
      this.multipleSelection = selection
      this.isSingle = selection.length !== 1
      this.isMultiple = !selection.length
    },
    openUploadDialog() {
      this.resetUploadDialog()
      this.uploadDialog.visible = true
    },
    confirmUploadDialog() {
      this.$refs.upload.submit()
    },
    resetUploadDialog() {
      this.uploadDialog.visible = false
      this.uploadData.params.customerNo = null
    },
    handleDownloadTemplate() {
      SalesOrderApi.importTemplate().then(response => {
        this.$common.download(response.data)
      })
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.uploadData.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.uploadDialog.visible = false
      this.uploadData.isUploading = false
      this.$refs.upload.clearFiles()
      this.$alert(response.data ? response.data : response.msg, '导入结果', { dangerouslyUseHTMLString: true })
      this.queryParams.status = null
      this.handleQuery()
    },
    resetQuery() {
      this.page.current = 1
      this.queryParams = {
        customerNo: null,
        custSalesOrderNo: null,
        custSalesOrderItemNo: null,
        orderTimeTo: null,
        orderTimeFr: null,
        status: null,
        errorFlag: null,
        receiverName: null,
        receiverMobile: null,
        custSpuId: null,
        custSkuId: null,
        storeId: null,
        isValid: this.$constant.Y,
        sortProperty: null,
        sortDirection: null
      }
      this.handleQuery()
    },
    orderTypeFormat(type) {
      return this.$common.getDictValueName(this.options.orderTypeOptions, type)
    },
    settleStatusFormat(type) {
      return this.$common.getDictValueName(this.options.settleStatusOptions, type)
    },
    orderSourceFormat(source) {
      return this.$common.getDictValueName(this.options.sourceTypeOptions, source)
    },
    orderStatusFormat(status) {
      return this.$common.getDictValueName(this.options.salesOrderStatusOptions, status)
    },
    payTypeFormat(type) {
      return this.$common.getDictValueName(this.options.payTypeOptions, type)
    }
  }
}
</script>
